

<template>

  <div class="addUserInfo">
     <ViewTitle text="凭证信息" />
    <div class="box1">
        
      <div>
        <span style="width:100px">就诊凭证类型:</span>
        <div>
            <el-radio-group v-model="params.cert_type">
              <el-radio label="01">电子凭证</el-radio>
              <el-radio label="02">身份证 </el-radio>
              <el-radio label="03"> 社保卡</el-radio>
            </el-radio-group>
        </div>
      </div>
      
       <div>
       <span style="width:100px">就诊凭证编号:</span>
        <el-input
          
          size="mini"
          v-model="params.cert_no"
          placeholder="诊凭证编号"
        ></el-input>
      </div>
      <div>
        <span>卡识别码:</span>
        <el-input
          
          size="mini"
          v-model="params.card_sn"
          placeholder="卡识别码"
        ></el-input>
      </div>
        <div >
            <span>选择患者:</span>
            <selectInput :thatF="this"></selectInput>
          
          </div>
    
      <!-- <div> -->
        <div>
      <span>异地:</span>
         <el-checkbox v-model="params.is_yd"></el-checkbox>
      </div>
             <div v-if="params.is_yd">
      <span>参保地:</span>
                     <el-input v-model="params.insuplc_admdvs"></el-input>
     </div>
       <div>
          <el-button  class="butB_Add"  @click="selectUserInfo()">读取个人基本信息</el-button>
           <el-button  class="butB_Add"  @click="readCard()">读卡</el-button>
            <el-button  class="butB_Add"  @click="selectUserInfo2()">查询是否备案</el-button>
            
      </div>
       <!-- </div> -->
    </div>
      
        
   
    <ViewTitle text="基础信息" />
     <div class="box1">
      <div>
        <span>人员编号:</span>
        <el-input
          size="mini"
          disabled
          v-model="baseinfo.psn_no"
       >
        </el-input>
      </div>
        <div>
        <span>证件类型:</span>
        <el-input
          size="mini"
          disabled
          v-model="baseinfo.psn_cert_type"
       >
        </el-input>
      </div>
        <div>
        <span>证件号码:</span>
        <el-input
          size="mini"
          disabled
          v-model="baseinfo.certno"
       >
        </el-input>
      </div>
        <div>
        <span>姓名:</span>
        <el-input
          size="mini"
          disabled
          v-model="baseinfo.psn_name"
       >
        </el-input>
      </div>
        <div>
        <span>性别:</span>
        <el-input
          size="mini"
          disabled
          v-model="baseinfo.gend"
       >
        </el-input>
      </div>
        <div>
        <span>名族:</span>
        <el-input
          size="mini"
          disabled
          v-model="baseinfo.naty"
       >
        </el-input>
      </div>
        <div>
        <span>出生日期:</span>
        <el-input
          size="mini"
          disabled
          v-model="baseinfo.brdy"
       >
        </el-input>
      </div>
        <div>
        <span>年龄:</span>
        <el-input
          size="mini"
          disabled
          v-model="baseinfo.age"
       >
        </el-input>
      </div>
    
    </div> 
     <ViewTitle text="参保信息" v-if="insuinfo.length>0" />

     <div v-if="insuinfo.length>0"> 
          <el-table
          :data="insuinfo"
          border
          style="width: 100%">
           <template v-for="(item, index) in $baseBai['yibaoInfo']['list']">
              
               <el-table-column :key="index" :width="item.width" v-if="item.prop == 'redio'" :prop="item.prop" :label="item.label" >
                        <template slot-scope="scope"> 
                            <div> <el-radio v-model="params.insutype" @change="redioChange(scope.row)" :label="scope.row.insutype"> &nbsp; </el-radio> </div>
                        </template>
              </el-table-column> 
                <el-table-column :key="index" :width="item.width" v-else-if="item.prop == 'insutype'" :prop="item.prop" :label="item.label" >
                        <template slot-scope="scope">
                            <div v-if="scope.row.insutype">{{  (yibao_insutype.find(v=>v.value==scope.row.insutype))?(yibao_insutype.find(v=>v.value==scope.row.insutype)).name:scope.row.insutype }}</div>
                        </template>
              </el-table-column> 
               <el-table-column :key="index" :width="item.width" v-else-if="item.prop == 'psn_type'" :prop="item.prop" :label="item.label" >
                        <template slot-scope="scope">
                            <div v-if="scope.row.psn_type">{{  (yibao_psn_type.find(v=>v.value==scope.row.psn_type))?(yibao_psn_type.find(v=>v.value==scope.row.psn_type)).name:scope.row.psn_type }}</div>
                        </template>
              </el-table-column>
                   <el-table-column :key="index" :width="item.width" v-else-if="item.prop == 'cvlserv_flag'" :prop="item.prop" :label="item.label" >
                        <template slot-scope="scope">
                            <div v-if="scope.row.cvlserv_flag">{{  scope.row.cvlserv_flag==1?'是':'否'}}</div>
                        </template>
              </el-table-column>
   <el-table-column :key="index" :width="item.width" v-else-if="item.prop == 'psn_insu_stas'" :prop="item.prop" :label="item.label" >
                        <template slot-scope="scope">
                            <div v-if="scope.row.psn_insu_stas">{{   ($baseBai['yibaoInfo']['status'].find(v=>v.value==scope.row.psn_insu_stas))?($baseBai['yibaoInfo']['status'].find(v=>v.value==scope.row.psn_insu_stas)).label:scope.row.psn_insu_stas}}</div>
                        </template>
              </el-table-column>
              
             <el-table-column :key="index" v-else :width="item.width"  :prop="item.prop" :label="item.label" > </el-table-column>
           </template>
           
        </el-table>

         
    </div>
   

     <el-dialog title="备案" :close-on-click-modal="false"  :modal="false"   :destroy-on-close="true" v-if="params.beianShow" :modal-append-to-body="true" :visible.sync="params.beianShow">
                  <beian :thatF="this"></beian>
     </el-dialog>
        <el-dialog title="备案信息" :close-on-click-modal="false"  :modal="false"   :destroy-on-close="true"  :modal-append-to-body="true" :visible.sync="beianShow2">
                 <el-table
          :data="tdatalist"
          border
          style="width: 100%">
           <template v-for="(item, index) in titlelist">
              
       
              
             <el-table-column :key="index" :width="item.width"  :prop="item.prop" :label="item.label" > </el-table-column>
           </template>
           
        </el-table>
     </el-dialog>
    <div class="buts">
          
        
          <el-button   class="butB_Add"  @click="next()">下一步</el-button>
         
    </div>
  </div>
</template>
<script>
let t;
import selectInput from "@/components/select"
import beian from "./beian"
import ViewTitle from "@/forComponents/viewTitle/index.vue";
import { mapState,mapActions } from "vuex";
export default {
  props: ['thatF'],
  data() {
    return {
       setSelectInput:{
          placeholder:'请输入病人姓名',
          key:'patient',
          url:'postMemberIndex',
         keyword:'',
         id:'',

        list:[
        
          {label:'姓名',prop:'name'},
          {label:'卡号',prop:'id_card',width:200},
          {label:'生日',prop:'birthday',width:100},
        ],

      },

      tdatalist:[],
      titlelist: [
          { prop: "psn_name", label: "备案患者" },
            { prop: "opsp_dise_name", label: "疾病名称" },
              { prop: "opsp_dise_code", label: "疾病编码" },
              { prop: "begndate", label: "开始时间" },
           
            { prop: "enddate", label: "结束时间" },
             { prop: "ide_fixmedins_name", label: "备案机构" },
            { prop: "ide_fixmedins_no", label: "机构代码" },
               { prop: "diag_dr_name", label: "诊断医生" },
            { prop: "diag_dr_codg", label: "医生编号" },
           
            { prop: "addr", label: "地址",  },
            
            
          
        ], 
        beianShow2:false,
      params:{
        cert_type:'', //凭证类型
        cert_no:'',  //凭证号码
        card_sn:'', //卡识别码  类型为社保卡时必填
        userinfo:'',
        beianShow:false,
        type:false,

        insutype:'',
      is_yd:false,
        insuplc_admdvs:'',

        selectData:{},

  
        
      },
     
     baseinfo:{},
    insuinfo:[],
   
    };
  },
  mounted(){
    t=this;
  
  
  },
 
  methods: {
      readCard(){
       return t.$message.error("维护中.....")
    },
      redioChange(item){
         t.params.selectData=item;
      },
  
 
    next(){
     
      if(!t.params.type){
          return t.$message.error("请些读取社保信息")
      }

      if(!t.params.insutype){
            return t.$message.error("请选择险种信息")
      }
      this.params.beianShow=true
    },
    psn_cert_typeChange(item){
      if(item=='01'){
        t.params.placeholder_certno='电子凭证令牌';
      }else  if(item=='02'){
        t.params.placeholder_certno='身份证号';  
      }else  if(item=='03'){
        t.params.placeholder_certno='会保障卡卡号';
      }
      console.log("item2",item)
    },
    selectUserInfo(){
       if(!t.params.cert_type){
             return t.$message.error('请选择就诊凭证类型')
          }
          if(!t.params.cert_no){
             return t.$message.error('请输入就诊凭证编号')
          }
       if(!t.setSelectInput.id){
             return t.$message.error('请选择患者')
          }
      let d={
        cert_no:t.params.cert_no,
        cert_type:t.params.cert_type,
        card_sn:t.params.card_sn,
        member_id:t.setSelectInput.id,
        is_yd:t.params.is_yd?1:'',
        insuplc_admdvs:t.params.insuplc_admdvs
      }
      
      if(t.params.cert_type=='3'&&!t.params.card_sn){
        return t.$message.error('请输入卡识别码')
      }

      this['_API'].getmemberGetInfo(d).then(res=>{
        if(res.code==200){
            t.params.type=true;
            t.baseinfo=res.data.baseinfo;
            t.insuinfo=res.data.insuinfo;
            t.baseinfo.gend= this.$baseYiBao.gend.find(l=>l.key==t.baseinfo.gend).name;
           
            t.baseinfo.psn_cert_type=  this.dict_psn_cert_type.find(v=>v.value==parseInt(t.baseinfo.psn_cert_type)).name;  
            t.baseinfo.naty=  this.dict_naty.find(v=>v.value==parseInt(t.baseinfo.naty)).name;  
        }
      })
    },
   
  selectUserInfo2(){

       if(!t.setSelectInput.id){
             return t.$message.error('请选择患者')
          }
      let d={
        psn_no:this.baseinfo.psn_no
      }
      
      if(t.params.cert_type=='3'&&!t.params.card_sn){
        return t.$message.error('请输入卡识别码')
      }

      this['_API'].queryPsnSlowDisease(d).then(res=>{
        if(res.code==200){
           this.tdatalist=res.data
           this.beianShow2=true
        }
       
      })
    },

    
    
  },
    computed: {
    ...mapState({
      dict_psn_cert_type: state => state.dictBai.dict_psn_cert_type,
      dict_naty: state => state.dictBai.dict_naty,
      yibao_insutype:state => state.dictBai.yibao_insutype,
      yibao_psn_type:state => state.dictBai.yibao_psn_type,
    }),
  },
  components: {
    ViewTitle,
    beian,
    selectInput,
    //  FormInfo
  },
};
</script>
<style lang='scss' scoped>
.addUserInfo {
 padding: 0 4%;
  .box1 {
    display: flex;
    flex-wrap: wrap;
    padding: 20px 0;
    > div {
      position: relative;
      width: 33%;
      display: flex;
      align-items: center;
      // justify-content: center;
      margin-bottom: 20px;

      > span {
        display: inline-block;
        width: 100px;
      }
      /deep/ .el-input {
        width: 180px;
      }
    }
  }
  .box3 {
    margin: 20px 0;
  }

  .dukaBut {
    margin: 0px 0 20px;
  }
}

.buts{
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    button{
        

    width: 200px;
    // position: absolute;
    bottom: 28px;
    right: 45px;
    }
}


</style>